package com.ysdz.tibetan.tibetanmini.user.controller;

import com.ysdz.tibetan.tibetanmini.user.beans.Consumer;
import com.ysdz.tibetan.tibetanminicommons.common.ReturnMsg;
import com.ysdz.tibetan.tibetanmini.user.dao.UsersMapper;
import com.ysdz.tibetan.tibetanmini.user.service.ConsumerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource;

@CrossOrigin
@RestController
@RequestMapping("/user")
@Api(value = "实现用户相关操作", tags = "用户信息控制器")
public class UserController {

    @Resource
    private ConsumerService consumerService;

    @ApiOperation("用户列表接口")
    @GetMapping("/userList")
    public ReturnMsg getUserList(){
        return consumerService.getUserList();
    }

//    @ApiOperation("用户登录接口")
//    @ApiImplicitParams({
//            @ApiImplicitParam(dataType = "string", name = "username", value = "用户登录账号", required = true),
//            @ApiImplicitParam(dataType = "string", name = "password", value = "用户登录密码", required = true)
//    })
//    @GetMapping("/login")
//    public ReturnMsg login(@RequestParam("username") String name,
//                           @RequestParam(value = "password") String pwd){
//        ReturnMsg resultVo = consumerService.checkLogin(name, pwd);
//        return resultVo;
//    }

//    @ApiOperation("用户注册接口")
//    @ApiImplicitParams({
//            @ApiImplicitParam(dataType = "string", name = "username", value = "用户注册账号", required = true),
//            @ApiImplicitParam(dataType = "string", name = "password", value = "用户注册密码", required = true)
//    })
//    @PostMapping("/regist/{username}/{password}")
//    public ReturnMsg regist(@PathVariable("username") String username, @PathVariable("password") String password){
//        return consumerService.userRegist(username, password);
//    }

    @ApiIgnore
    @RequestMapping("/test")
    public Consumer login01(String name){
        return consumerService.findUserByUsername(name);
    }

}
